<?php
require_once '../libs/app.config.php';
session_start ();
if ($_SESSION ['LoginId'] == false) {
	header ( "Location:login.php" );
}
($charset == 'zh_CN') ? $charset = 'cn' : null;

if ($_GET ['orderId']) 
{	
	$tempId = $_GET ['orderId'];
	$sql2 = "select orderId, origin, destination, items from orders where orderId = '" .$tempId. "'";
	$query2 = $tpm->query ( $sql2 );
	$rows = $tpm->fetch_array ( $query2 );
	$list = array (
			"orderId" => $rows ['orderId'],
			"origin" => $rows ['origin'],
			"destination" => $rows ['destination'],
			"items" => $rows ['items']
	);}

if ($_GET ['act'] == 'edit')
{
	$sql = "update orders set origin = '" . $origin . "', destination = '" . $destination . "', items = '" . $items . "' where orderId = '" . $orderId . "'";
	
	$result = $tpm->query ( $sql);
	if ($result > 0)
		echo "<script>alert('Order: {$orderId} is updated successfully!');location.href=('ongoing_orders_list.php');</script>";
		
}

// print_r($list);exit();
require_once (INCLUDE_PATH . 'template.inc.php'); // 模板类及对象$tpl的加载
$tpl->assign ( "list", $list );
$tpl->display ( "orders_edit.html" );
?>

